package com.videoaggre.zcl.ui.fragment

import android.os.Bundle
import android.view.View
import com.videoaggre.zcl.R
import com.videoaggre.zcl.helper.RefreshHelper
import com.videoaggre.zcl.ui.adapter.BaseRecyclerAdapter
import kotlinx.android.synthetic.main.activity_base_refresh.*

/**
 * 在initview中初始化适配器
 */
abstract class BaseRefreshFragment<T>(layoutResID: Int? = R.layout.activity_base_refresh) : BaseFragment(layoutResID) {
    protected lateinit var mRefreshHelper: RefreshHelper<T, MutableList<T>>
    protected lateinit var mBaseRecyclerAdapter: BaseRecyclerAdapter<*, T>
    override fun initView(rootView: View?, savedInstanceState: Bundle?) {
        mRefreshHelper = RefreshHelper(refreshLayout = refreshLayout, recyclerView = recyclerView, mBaseRecyclerAdapter = mBaseRecyclerAdapter) { onReload() }
    }

    override fun initData(rootView: View?, savedInstanceState: Bundle?) {
        onReload()
    }

    abstract fun onReload()
}